<!--

    Copyright (C) 2015 The Gravitee team (http://gravitee.io)

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

            http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<div class="gv-page-container">
  <a [routerLink]="['..']" class="gv-back-link"><small><< Back to roles</small></a>
  <h1>New Role</h1>
  <div>
    <form (ngSubmit)="create()" #roleForm="ngForm" fxLayout="column" fxFlex="70">
      <div class="gv-form-section">
        <mat-form-field *ngIf="organizationContext" appearance="outline" floatLabel="always">
          <mat-label>Assignable Type</mat-label>
          <mat-select placeholder="Type" [(ngModel)]="role.assignableType" name="type" required>
            <mat-option *ngFor="let roleType of roleTypes" [value]="roleType">{{ roleType }}</mat-option>
          </mat-select>
          <mat-hint>A type the role can be assign to.</mat-hint>
        </mat-form-field>

        <mat-form-field appearance="outline" floatLabel="always">
          <mat-label>Name</mat-label>
          <input matInput type="text" placeholder="Name" name="name" [(ngModel)]="role.name" required>
          <mat-hint>A name for your role.</mat-hint>
        </mat-form-field>

        <mat-form-field appearance="outline" floatLabel="always">
          <mat-label>Description</mat-label>
          <input matInput type="text" placeholder="Description" name="description" [(ngModel)]="role.description">
          <mat-hint>A description for your role.</mat-hint>
        </mat-form-field>
      </div>
      <div fxLayout="row" fxLayoutAlign="end">
        <a mat-button [routerLink]="['..']" style="margin-right: 20px;">CANCEL</a>
        <button mat-raised-button [disabled]="!roleForm.valid || roleForm.pristine" type="submit">CREATE</button>
      </div>
    </form>
    <div class="gv-page-description" fxFlex>
      <h3>Role ?</h3>
      <div class="gv-page-description-content">
        <p>
          Role determines how users can access protected resources.
          <span *ngIf="!organizationContext">Each role has a set of permissions to limit user actions.</span>
        </p>
        <div *ngIf="organizationContext">
          <p>
            Each role has a scope to specify what a user can do on a specific part of the Admin Portal.
          </p>
          <small>
            <b><i>MANAGEMENT : </i></b> Platform settings<br>
            <b><i>DOMAIN : </i></b> Security domain settings<br>
            <b><i>APPLICATION : </i></b> Application settings<br>
          </small>
        </div>
      </div>
    </div>
  </div>
</div>
